Various fixes to fix the "we don't choose direct routes" problem. - #2307
Conversation
We have a seed, which is for (future!) unit testing consistency. This makes it change every time, so our pay_direct_test is more useful. I tried restarting the noed around the loop, but it tended to fail rebinding to the same port for some reason? Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This is the direct cause of the failure of the original test_pay_direct test and it makes sense: invoice routehints may not be necessary, so try without them *first* rather than last. We didn't mention the use of routehints in CHANGELOG at all yet, so do that now. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
11de198 to
09de978
Compare
The test sometimes passes: our routing logic always chooses between the shorter of two equal-cost routes (because we compare best with < not <=). By adding another hop, we add more noise, and by making the alternate route fee 0 we provide the worst case. But to be fair, we make the amount of the payment ~50c (15,000,000 msat), and increase our cltv-delay to 14 and fee-base 1000 to match mainnet. The final patch shows the effect of this choice. Otherwise our risk penalty is completely in the noise on mainnet which has the vast majority of fees set at 1000msat + 1ppm. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We used a u16, and a 1000 multiplier, which meant we wrapped at riskfactor 66. We also never undid the multiplier, so we ended up applying 1000x the riskfactor they specified. This changes us to pass the riskfactor with a 1M multiplier. The next patch changes the definition of riskfactor to be more useful. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We were only comparing by total msatoshis. Note, this *still* isn't sufficient to fix our indirect problem, as our risk values are all 1 (the minimum): lightning_gossipd(25480): 2 hop solution: 1501990 + 2 lightning_gossipd(25480): 3 hop solution: 1501971 + 3 ... lightning_gossipd(25480): => chose 3 hop solution Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Up until now, riskfactor was useless due to implementation bugs, and also the default setting is wrong (too low to have an effect on reasonable payment scenarios). Let's simplify the definition (by assuming that P(failure) of a node is 1), to make it a simple percentage. I examined the current network fees to see what would work, and under this definition, a default of 10 seems reasonable (equivalent to 1000 under the old definition). It is *this* change which finally fixes our test case! The riskfactor is now 40msat (1500000 * 14 * 10 / 5259600 = 39.9), comparable with worst-case fuzz is 50msat (1001 * 0.05 = 50). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
09de978 to
8e210e9
Compare
| during the process. The 'riskfactor' floating-point field controls | ||
| this tradeoff; it is the annual cost of your funds being stuck (as a | ||
| percentage), multiplied by the percentage chance of each node failing. | ||
| percentage). |
There was a problem hiding this comment.
percentage of what? channel capacity? Sorry, read the full context now, percentage of the payment amount
Travis timed out. Waiting for three fundchannel commands depends on the bitcoind polling interval (30 seconds), and then waiting for gossip propagation requires two propagation intervals (120 seconds). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
|
ACK bc1c0af Though I seem to have gotten lost in the maxfeepercent vs fuzz factor vs riskfactor logic: a 5% fuzz allows us to use routes that are up to 5% worse than what exactly? |
| pc->excludes = tal_arr(cmd, const char *, 0); | ||
| pc->ps = add_pay_status(pc, b11str); | ||
| /* We try first without using routehint */ | ||
| pc->current_routehint = NULL; |
| fail, and it would cost you 20% per annum if that happened, | ||
| 'riskfactor' would be 20. | ||
| For example, if you thought the inconvenience of having funds stuck was | ||
| worth 20% per annum interest, 'riskfactor' would be 20. |
There was a problem hiding this comment.
Restating this to confirm I'm understanding: riskfactor is a way of dynamically valuing shorter routes, by accounting for the potential loss of liquidity in the case that a payment gets stuck along the route. i.e. the more hops in a route (and payment value) the higher the riskfactor. In some sense, this makes higher fee yet shorter routes more attractive as the possibility for getting stuck is lowered due to less chances of a link failure en route.
This was something of a saga:
paytries routehints first, so sometimes we went indirect because we were following the routehint(which did change around the loop).
Fixes: #2119
Closes: #2168
Closes: #2144